package edu.hrbu.systemadmin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import edu.hrbu.systemadmin.annotation.HasPerms;
import edu.hrbu.systemadmin.entity.YdlUser;
import edu.hrbu.systemadmin.service.IYdlUserService;
import edu.hrbu.systemadmin.util.R;
import edu.hrbu.systemadmin.vo.LoginUserVo;
import edu.hrbu.systemadmin.vo.UserPageVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author 徐登宇
 * @since 2023-04-22
 */
@RestController
@RequestMapping("/user")
public class YdlUserController extends BaseController {

    @Resource
    private IYdlUserService ydlUserService;


    @HasPerms(perms = {"system:user"})
    @GetMapping("/list")
    public R list(UserPageVo userPageVo) {
        Page<YdlUser> pageModel = ydlUserService.pageQueryWithCondition(userPageVo);
        return R.ok(pageModel);
    }

    @GetMapping("/info")
    public R info(){
        LoginUserVo loginUser = getLoginUser();
        // 要通过userId获取到对应的权限和菜单
        Map<String, List> info=ydlUserService.info(loginUser);
        return R.ok(info);
    }

}
